package com.zzz.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zhuzhizun
 * @date 2021/9/1
 */
@Configuration
@ConditionalOnClass({ThreadPoolExecutor.class})
public class ThreadPoolAutoConfiguration {


    @Bean("myThreadPool")
    public ThreadPoolExecutor myThreadPool(){
        return new ThreadPoolExecutor(2,10,10,
                TimeUnit.SECONDS,new ArrayBlockingQueue<>(5));
    }



}
